/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.wii.elpro.dao.hb;

import com.wii.elpro.entity.Spdcf;
import com.wii.elpro.entity.Quotation;
import com.wii.elpro.entity.Inquery;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author hp02
 */
public class ScatteredFunction {
    
    public static List<Spdcf> getReadySpdcf(List<Spdcf> spdcf, List<Quotation> quotations) {
        List<Spdcf> listSpdcf = new ArrayList<Spdcf>();
        List<Spdcf> sp = new ArrayList<Spdcf>();
        
        for(Quotation q:quotations) {
            sp.add(q.getSpdcf());
        }

//            This is so bad codes, to many loop
        for(Spdcf s:spdcf) {
            if(!sp.contains(s) && s.getWasKonfirmByFinance()==1 && s.getWasKonfirmByProduction()==1) {
                listSpdcf.add(s);
            }
        }
        
        return listSpdcf;
    }
    
    public static List<Inquery> getNewInquiry(List<Inquery> inquiry, List<Spdcf> spdcf) {
        List<Inquery> listInquiry = new ArrayList<Inquery>();
        List<Long> inquiries = new ArrayList<Long>();
        
        for(Spdcf s:spdcf) {
            inquiries.add(s.getInquery().getId());
        }

//            This is so bad codes, to many loop
//        if(inquiry.contains(inquiries.get(0))) {
//            System.out.println(inquiry.get(0).getId());
//            System.out.println(inquiries.get(0).getId());
//            System.out.println("sama");
//        }
        
        for(Inquery i:inquiry) {
            if(!inquiries.contains(i.getId())) {
                listInquiry.add(i);
//                            System.out.println("------------------->DONG");
//                        break;
            }
        }
        
        return listInquiry;
    }
}
